home *** CD-ROM | disk | FTP | other *** search
/ Aminet 8 / Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso / Aminet / dev / gcc / libnixV1_0.lha / gnu / libnix-sources.lha / sources / headers / stabs.h < prev    next >
C/C++ Source or Header  |  1995-01-22  |  3KB  |  103 lines

  1. #ifndef _STABS_H_
  2. #define _STABS_H_
  3.  
  4. /* These are some macros for handling of symboltable information
  5.  */
  6.  
  7. /* linker can use symbol b for symbol a if a is not defined */
  8. #define ALIAS(a,b) asm(".stabs \"_" #a "\",11,0,0,0\n.stabs \"_" #b "\",1,0,0,0")
  9.  
  10. /* add symbol a to list b (type c (22=text 24=data 26=bss)) */
  11. #define ADD2LIST(a,b,c) asm(".stabs \"_" #b "\"," #c ",0,0,_" #a )
  12.  
  13. /* Install private constructors and destructors pri MUST be -127<=pri<=127 */
  14. #define ADD2INIT(a,pri) ADD2LIST(a,__INIT_LIST__,22); \
  15.                         asm(".stabs \"___INIT_LIST__\",20,0,0," #pri "+128")
  16. #define ADD2EXIT(a,pri) ADD2LIST(a,__EXIT_LIST__,22); \
  17.                         asm(".stabs \"___EXIT_LIST__\",20,0,0," #pri "+128")
  18.  
  19. /* Add to library list */
  20. #define ADD2LIB(a) ADD2LIST(a,__LIB_LIST__,24)
  21.  
  22. /* This one does not really handle symbol tables
  23.  * it's just pointless to write a header file for one macro
  24.  *
  25.  * define a as a label for an absolute address b
  26.  */
  27. #define ABSDEF(a,b) asm("_" #a "=" #b ";.globl _" #a )
  28.  
  29. /* Generate assembler stub for a shared library entry
  30.  * and add it to the jump table
  31.  * ADDTABL_X(name,...)    means function with X arguments
  32.  * ADDTABL_END()    ends the list
  33.  * Usage: ADDTABL_2(AddHead,a0,a1);
  34.  * No more than 4 arguments supported, use structures!
  35.  */
  36.  
  37. #define _ADDTABL_START(name)        \
  38. asm(".globl ___" #name);        \
  39. asm("___" #name ":\tmovel a4,sp@-")
  40.  
  41. #define _ADDTABL_ARG(arg)        \
  42. asm("\tmovel " #arg ",sp@-")
  43.  
  44. #define _ADDTABL_CALL(name)        \
  45. asm("\tmovel a6@(40:W),a4");        \
  46. asm("\tbsr _" #name)
  47.  
  48. #define _ADDTABL_END0(name,numargs)    \
  49. asm("\tmovel sp@+,a4");            \
  50. asm("\trts");                \
  51. ADD2LIST(__##name,__FuncTable__,22)
  52.  
  53. #define _ADDTABL_END2(name,numargs)    \
  54. asm("\taddqw #4*" #numargs ",sp");    \
  55. asm("\tmovel sp@+,a4");            \
  56. asm("\trts");                \
  57. ADD2LIST(__##name,__FuncTable__,22)
  58.  
  59. #define _ADDTABL_ENDN(name,numargs)    \
  60. asm("\taddaw #4*" #numargs ",sp");    \
  61. asm("\tmovel sp@+,a4");            \
  62. asm("\trts");                \
  63. ADD2LIST(__##name,__FuncTable__,22)
  64.  
  65. #define ADDTABL_0(name)            \
  66. _ADDTABL_START(name);            \
  67. _ADDTABL_CALL(name);            \
  68. _ADDTABL_END0(name,0)
  69.  
  70. #define ADDTABL_1(name,arg1)        \
  71. _ADDTABL_START(name);            \
  72. _ADDTABL_ARG(arg1);            \
  73. _ADDTABL_CALL(name);            \
  74. _ADDTABL_END2(name,1)
  75.  
  76. #define ADDTABL_2(name,arg1,arg2)    \
  77. _ADDTABL_START(name);            \
  78. _ADDTABL_ARG(arg2);            \
  79. _ADDTABL_ARG(arg1);            \
  80. _ADDTABL_CALL(name);            \
  81. _ADDTABL_END2(name,2)
  82.  
  83. #define ADDTABL_3(name,arg1,arg2,arg3)    \
  84. _ADDTABL_START(name);            \
  85. _ADDTABL_ARG(arg3);            \
  86. _ADDTABL_ARG(arg2);            \
  87. _ADDTABL_ARG(arg1);            \
  88. _ADDTABL_CALL(name);            \
  89. _ADDTABL_ENDN(name,3)
  90.  
  91. #define ADDTABL_4(name,arg1,arg2,arg3,arg4) \
  92. _ADDTABL_START(name);            \
  93. _ADDTABL_ARG(arg4);            \
  94. _ADDTABL_ARG(arg3);            \
  95. _ADDTABL_ARG(arg2);            \
  96. _ADDTABL_ARG(arg1);            \
  97. _ADDTABL_CALL(name);            \
  98. _ADDTABL_ENDN(name,3)
  99.  
  100. #define ADDTABL_END() asm(".stabs \"___FuncTable__\",20,0,0,-1")
  101.  
  102. #endif
  103.